<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Basic Form </title>

    <!-- ================= Favicon ================== -->

    <!-- Styles -->
    <link href="__VIS__/css/lib/font-awesome.min.css" rel="stylesheet">
    <link href="__VIS__/css/lib/themify-icons.css" rel="stylesheet">
    <link href="__VIS__/css/lib/menubar/sidebar.css" rel="stylesheet">
    <link href="__VIS__/css/lib/bootstrap.min.css" rel="stylesheet">
    <link href="__VIS__/css/lib/unix.css" rel="stylesheet">
    <link rel="stylesheet" href="__VIS__/js/btr/jquery.treetable.css">
    <link rel="stylesheet" href="__VIS__/js/btr/jquery.treetable.theme.default.css">
    <link href="__VIS__/css/style.css" rel="stylesheet">
    <style>
        tbody tr td:last-child {
            text-align: left;
        }
    </style>

</head>

<body>
<div class="container-fluid">
    <div class="row">
        <div class="col-lg-8 p-r-0 title-margin-right">
            <div class="page-header">
                <div class="page-title">
                    <h1>添加/编辑角色</h1>
                </div>
            </div>
        </div>
        <!-- /# column -->
        <div class="col-lg-4 p-l-0 title-margin-left">
            <div class="page-header">
                <div class="page-title">
                    <ol class="breadcrumb text-right">
                        <li><a href="#">管理员</a></li>
                        <li><a href="{:url('index')}">角色列表</a></li>
                        <li class="active">添加/编辑角色</li>
                    </ol>
                </div>
            </div>
        </div>
        <!-- /# column -->
    </div>
    <!-- /# row -->
    <section id="main-content">
        <div class="row">
            <div class="col-lg-12">
                <div class="card alert">
                    <div class="card-header">
                        <h4>添加/编辑角色</h4>
                        <div class="card-header-right-icon">
                            <ul>
                                <li class="card-close" data-dismiss="alert"><i class="ti-close"></i></li>
                                <li class="doc-link"><a href="#"><i class="ti-link"></i></a></li>
                                <li class="page-refresh"><i class="fa fa-refresh"></i> 刷新页面</li>
                            </ul>
                        </div>
                    </div>
                    <div class="card-body">
                        <div class="basic-elements">
                            <form class="vis_form">
                                <div class="row">
                                    <div class="col-lg-6">

                                        <div class="form-group">
                                            <label>角色名</label>
                                            <input type="text" name="name" class="form-control" placeholder="请输入" {notempty name="info.cate.name"}value="{$info.cate.name}"{/notempty}>
                                            <span class="help-block">
														<small>角色名称 </small>
													</span>
                                        </div>

                                        <div class="form-group">
                                            <label>描述</label>
                                            <textarea class="form-control" rows="4" placeholder="Text input" name="desc">{notempty name="$info.cate.desc"}{$info.cate.desc}{/notempty}</textarea>
                                        </div>
                                        <div class="form-group">
                                            <label>赋予权限</label>
                                            <table id="treeTable" class="table">
                                                {volist name="$info.menu" id="data"}
                                                {notempty name="$data.list"}
                                                <tr data-tt-id="{$data.id}" data-tt-parent-id="{$data.pid}"><td>{$data.name}</td></tr>
                                                {volist name="$data.list" id="vo"}
                                                <tr data-tt-id="{$vo.id}" data-tt-parent-id="{$vo.pid}">
                                                    {eq name="vo.is_display" value="1"}
                                                    <td>
                                                        <input type="checkbox"  name="admin_menu_id[]" value="{$vo.id}" {notempty name="$info.cate.permissions"}{volist name="$info.cate.permissions" id="datas"}{eq name="$datas" value="$vo.id"}checked {else /}{eq name="$vo.type" value="2"}checked disabled{/eq}{/eq}{/volist}{else /}{eq name="$vo.type" value="2"}checked disabled{/eq}{/notempty}>{$vo.name}
                                                    </td>
                                                    {else /}{eq name="vo.type" value="1"}
                                                    <td>
                                                        <input type="checkbox" name="admin_menu_id[]" value="{$vo.id}" {notempty name="$info.cate.permissions"}{volist name="$info.cate.permissions" id="datas"}{eq name="$datas" value="$vo.id"}checked {else /}{eq name="$vo.type" value="2"}checked disabled{/eq}{/eq}{/volist}{else /}{eq name="$vo.type" value="2"}checked disabled{/eq}{/notempty}>{$vo.name}
                                                    </td>
                                                    {/eq}
                                                    {/eq}
                                                </tr>
                                                {/volist}
                                                {else /}
                                                <tr>
                                                    <td>
                                                        <input type="checkbox"  name="admin_menu_id[]" value="{$data.id}" {notempty name="$info.cate.permissions"}{volist name="$info.cate.permissions" id="datas"}{eq name="$datas" value="$data.id"}checked{/eq}{/volist}{/notempty}>{$data.name}
                                                    </td>
                                                </tr>

                                                {/notempty}
                                                {/volist}
                                            </table>
                                        </div>
                                        {notempty name="$info.cate"}
                                        <input type="hidden" name="id" value="{$info.cate.id}">
                                        {/notempty}

                                        <div class="form-group">
                                            <a href="#" class="btn btn-default btn-outline vis_form_btn">立即提交</a>
                                        </div>
                                    </div>

                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
            <!-- /# column -->
            <!-- /# column -->
        </div>
        <!-- /# row -->
    </section>
</div>


<div id="search">
    <button type="button" class="close">×</button>
    <form>
        <input type="search" value="" placeholder="type keyword(s) here" />
        <button type="submit" class="btn btn-primary">Search</button>
    </form>
</div>
<!-- jquery vendor -->
<script src="__VIS__/js/lib/jquery.min.js"></script>
<script src="__VIS__/js/lib/jquery.nanoscroller.min.js"></script>
<!-- nano scroller -->
<script src="__VIS__/js/lib/menubar/sidebar.js"></script>
<script src="__VIS__/js/lib/preloader/pace.min.js"></script>
<!-- sidebar -->
<script src="__VIS__/js/lib/bootstrap.min.js"></script>
<!-- bootstrap -->
<script src="__VIS__/js/layui/layui.js"></script>
<script type="text/javascript" src="__VIS__/js/tree/bootstrap-table.js"></script>
<script type="text/javascript" src="__VIS__/js/tree/bootstrap-table-zh-CN.js"></script>
<script type="text/javascript" src="__VIS__/js/btr/jquery.treetable.js"></script>
<script>
    $(document).ready(function(){
        $("#treeTable").treetable({
            expandable : true,
            initialState:"collapsed",
            //expandable : true
            clickableNodeNames:false,//点击节点名称也打开子节点.
            indent : 30//每个分支缩进的像素数。
        });
    });

</script>

<!-- scripit init-->
<script>
    layui.use(['upload','layer'], function(){
        var layer=layui.layer;
                $('.page-refresh').on("click", function() {
            location.reload();
        });
        $('.vis_form_btn').click(function () {
            $.ajax({
                url:"{:url('admin/role/edit')}",
                type:'POST',
                dataType:'JSON',
                data:$('.vis_form').serialize(),
                success:function (res) {
                    if(res.code == 1){
                        layer.msg(res.msg,{icon:6},function () {
                            window.location.href=res.url;
                        })
                    }else {
                        layer.msg(res.msg,{icon:5})
                    }
                }
            })
        })
    })
</script>




</body>

</html>